package com.pattern.creation.builder;

public class Student {
	private String name;
	private int age;
	private int gender;

	@Override
	public String toString() {
		return "Student [age=" + age + ", gender=" + gender + ", name=" + name + "]";
	}

	public Student(Builder builder) {
		this.name = builder.name;
		this.age = builder.age;
		this.gender = builder.gender;
	}

	public static class Builder {
		private String name;
		private int age;
		private int gender;

		public Builder(String name) {
			super();
			this.name = name;
		}

		public Builder setAge(int age) {
			this.age = age;
			return this;
		}

		public Builder setGender(int gender) {
			this.gender = gender;
			return this;
		}

		public Student build() {
			return new Student(this);
		}

	}

	public static void main(String[] args) {
		Student lili = new Student.Builder("Lili").build();
		System.out.println(lili);
		Student lilei = new Student.Builder("Lilei").setAge(18).setGender(1).build();
		System.out.println(lilei);
	}
}
